package com.qinglei.recoup.system.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qinglei.recoup.system.domain.BedHealthBreathDailyData;
import com.qinglei.recoup.system.domain.BedHealthDailyStatistics;
import com.qinglei.recoup.system.domain.BedHealthQO;
import com.qinglei.recoup.system.domain.HealthSearchQO;
import com.qinglei.recoup.system.pojo.HealthDetailParamV1;
import com.qinglei.recoup.system.pojo.HealthRank;
import com.qinglei.recoup.system.pojo.HealthVO;
import com.qinglei.recoup.system.pojo.PageParam;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.time.LocalDate;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;

/**
 * @author syp
 */
@Mapper
public interface BedHealthDailyStatisticsMapper extends BaseMapper<BedHealthDailyStatistics> {

    /**
     * 分页查询健康数据
     *
     * @param pageParam
     * @param searchParam
     * @return
     */
    IPage<HealthVO> selectHealthPage(Page<HealthVO> pageParam, @Param("p") HealthSearchQO searchParam);

    /**
     * 分页查询健康数据
     *
     * @param param
     * @return
     */
    HealthVO selectBedHealth(@Param("p") BedHealthQO param);

    List<HealthRank> selectRank(@Param("startDate")LocalDate startDate);

    List<Map<String, Object>> selectScoreAndAHI(@Param("p")BedHealthQO bedHealthQO);

    List<BedHealthDailyStatistics> selectListByDate(@Param("startDate")LocalDate startDate);

    List<BedHealthDailyStatistics> getScoreByDate(@Param("bedId")Integer bedId,@Param("startDate") LocalDate startDate, @Param("endDate")LocalDate endDate);

    IPage<HealthVO> selectHealthPageV1(Page<HealthVO> page, @Param("p")HealthSearchQO healthSearchQO);

    Integer getSumScore(@Param("p")BedHealthQO bedHealthQO);

    BedHealthDailyStatistics selectOldHelthPage(Integer bedId);

    List<Map<String, Object>> selectSleepRule(@Param("p")HealthDetailParamV1 healthDetailParamV1);

    List<Map<String,Object>> selectHeartData(@Param("p")HealthDetailParamV1 healthDetailParamV1);

    List<Map<String, Object>> selectBreathData(@Param("p")HealthDetailParamV1 healthDetailParamV1);

    List<TreeMap<String,Object>> selectSleepTimeData(@Param("p") HealthDetailParamV1 healthDetailParamV1);

    List<TreeMap<String, Object>> selectOutBedNums(@Param("p")HealthDetailParamV1 healthDetailParamV1);

    List<TreeMap<String, Object>> selectAhiLists(@Param("p")HealthDetailParamV1 healthDetailParamV1);
}
